package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 字段所属，来自FieldType的belong
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/3/1 13:41
 * @since v1.0
 */
@Getter
public enum BelongEnum {
    /**
     * 字段所属
     */
    BASIC(1, "basic", "enum.belong.description.basic"),
    COMPLEX(2, "complex", "enum.belong.description.complex"),
    SYSTEM(3, "system", "enum.belong.description.system"),
    SAAS(4, "saas", "enum.belong.description.saas"),
    STOCK(5, "stock", "enum.belong.description.stock"),
    WARNING(6, "warning", "enum.belong.description.warning"),
    BATCH(6, "batch", "enum.belong.description.batch"),

    // 旗舰版字段
    ULTIMATE(7, "ultimate", ""),
    ;
    /**
     * 枚举值
     */
    private Integer code;
    /**
     * 英文描述basic   complex  system   saas:saas独有字段，暂时不显示在左侧控件框
     */
    private String alias;
    /**
     * 字段描述
     */
    private String description;

    BelongEnum(Integer code, String alias, String description) {
        this.code = code;
        this.alias = alias;
        this.description = description;
    }

    public static BelongEnum getByAlias(String alias) {
        for (BelongEnum belongEnum: values()) {
            if (belongEnum.getAlias().equals(alias)) {
                return belongEnum;
            }
        }
        return null;
    }

    public String getDescription() {
        return I18nMessageUtil.getMessage(description);
    }
}
